package com.grgbanking.it.scheduled;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.grgbanking.it.common.util.DateUtil;
import com.grgbanking.it.external.service.ISupplierService;

/**
 * 供应商相关的定时器
 * 
 * SupplierTask
 * 
 * @author 潘广伟
 * @Email p_3er@qq.com
 * @Date 2015-1-6 下午3:44:27
 * 
 * @version 1.0.0
 *
 */
@Component
public class SupplierTask {
	@Autowired
	private ISupplierService supplierService;
	
	/**
	 * 同步供应商到微信
	 * 每天23时触发
	 * supplierToWX
	 *  
	 * @exception 
	 * @since  1.0.0
	 */
	@Scheduled(cron = "0 0 23 * * ?")  
    public void supplierToWX() {  
        try {
        	System.out.println("同步供应商到微信:"+DateUtil.getInstance().todayShort());
			supplierService.updateToWX();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }  

	/**
	 * 发送出差信息到供应商微信
	 * 每6个小时执行一次
	 * supplierMsnToWX
	 *  
	 * @exception 
	 * @since  1.0.0
	 */
	@Scheduled(cron = "0 0/5 * * * ?")  
    public void supplierMsnToWX() {  
        try {
        	System.out.println("发送出差信息到供应商微信:"+DateUtil.getInstance().todayShort());
			supplierService.updateMsgToWX();
		} catch (Exception e) {
			e.printStackTrace();
		}
    }  
}
